perm filename EPUT.2[EAL,HE]2 blob sn#701192 filedate 1983-03-24 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00007 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	{$NOMAIN	Editor routines to Put things on the display }
C00028 00003	{ Externally defined routines from elsewhere: }
C00030 00004	(* print routines: putChar, put5, put10, putLine *)
C00039 00005	(* aux print routines: putReal, putInt, putVec, putTrans, putStrng, putTlist *)
C00046 00006	(* expression related routine: getExprLength *)
C00047 00007	(* Expression output routine:  putExpr *)
C00055 ENDMK
C⊗;
{$NOMAIN	Editor routines to Put things on the display }

const

	(* Constants from EDIT *)
      	maxLines = 28;		(* smaller on the 11 than on the 10 *)
      	maxPPLines = 18;
      	maxBpts = 25;
      	maxTBpts = 20;	(* max could be exceeded by huge case stmnt *)
	listinglength = 2000;	(* Length of Listingarray *)

(* Random type declarations for OMSI/SAIL compatibility *)

type

  byte = 0..255;	(* doesn't really belong here, but... *)
  ascii = char; 
  atext = text;

{ Define all the pointer types here }

vectorp = ↑vector;
transp = ↑trans;
strngp = ↑strng;
varidefp = ↑varidef;
statementp = ↑statement;
nodep = ↑node;
identp = ↑ident;
tokenp = ↑token;
reswordp = ↑resword;
cmoncbp = ↑cmoncb;
linerecp = ↑linerec;
cursorpp = ↑cursorp;	{Ron's style, not mine}

(* This one is used whenever a pointer is needed for which the 	*)
(* definition is missing from this file; naturally, all 	*)
(* pointers use the same space 					*)

dump = ↑integer;

scalar = real;

datatypes = (pconstype, varitype, svaltype, vectype, rottype, transtype,
	     frametype, eventtype, strngtype, labeltype, proctype, arraytype,
	     reftype, valtype, cmontype, nulltype, undeftype,
	     dimensiontype, mactype, macargtype, freevartype);


u = (used,free);
vector = record case u of
	   used: (refcnt: integer; val: array [1..3] of real);
	   free: (next: vectorp);
	 end;

trans = record case u of
	   used: (refcnt: integer; val: array [1..3,1..4] of real);
	   free: (next: transp);
	end;

cstring = packed array [1..10] of ascii;
c4str = packed array [1..4] of ascii;
c5str = packed array [1..5] of ascii;
c20str = packed array [1..20] of ascii;
linestr = packed array [1..130] of ascii;

strng = record
	  next: strngp;
	  ch: cstring;
	end;


(* statement definitions *)

stmntypes = (progtype, blocktype, coblocktype, endtype, coendtype,
		fortype, iftype, whiletype, untiltype, casetype,
		calltype, returntype,
		printtype, prompttype, pausetype, aborttype, assigntype,
		signaltype, waittype, enabletype, disabletype, cmtype,
		affixtype, unfixtype,
		movetype, operatetype, opentype, closetype, centertype,
		stoptype, retrytype,
		requiretype, definetype, macrotype, commenttype, dimdeftype,
		setbasetype, wristtype, tovaltype, declaretype, emptytype);
		(* more??? *)

statement = packed record
		next, last: statementp; (* ↑ to lexical tokens? *)
		stlab: varidefp;
		exprs: nodep;	(* any expressions used by this statement *)
		nlines: integer;
		bpt: boolean;
		case stype: stmntypes of
    progtype:	    (pcode: statementp; errors: integer);
	    end;

(* auxiliary definitions: variable, etc. *)


varidef = packed record
	    next,dnext: varidefp;
	    name: identp;
	    level: 0..255;	(* environment level *)
	    offset: 0..255;	(* environment offset *)
	    dtype: varidefp;	(* to hold the dimension info *)
	    tbits: 0..15;  (* special type bits: array = 1, proc = 2, ref = 4 & ? *)
	    dbits: 0..15;	(* for use by debugger/interpreter *)
	    case vtype: datatypes of
  arraytype:  (a: nodep);
  proctype:   (p: nodep);
  labeltype,
  cmontype:   (s: statementp);
  mactype:    (mdef: statementp);
  macargtype: (marg: tokenp);
  pconstype:  (c: nodep);
  dimensiontype: (dim: nodep);
	  end;


(* definition of the ubiquitous NODE record *)

nodetypes = (exprnode, leafnode, listnode, clistnode, colistnode, forvalnode,
		deprnode, viaptnode, apprnode, destnode, durnode,
		sfacnode, wobblenode, swtnode, nullingnode, wristnode, cwnode,
		arrivalnode, departingnode,
		ffnode, forcenode, stiffnode, gathernode, cmonnode, errornode,
		calcnode, arraydefnode, bnddefnode, bndvalnode,
		waitlistnode, procdefnode, tlistnode, dimnode, commentnode);

exprtypes =  (	svalop,					(* scalar operators *)
		sltop, sleop, seqop, sgeop, sgtop, sneop,	(* relations *)
		notop, orop, xorop, andop, eqvop,		(* logical *)
		saddop, ssubop, smulop, sdivop, snegop, sabsop, (* scalar ops *)
		sexpop, maxop, minop, intop, idivop, modop,
		sqrtop, logop, expop, timeop,			(* functions *)
		sinop, cosop, tanop, asinop, acosop, atan2op,	(* trig *)
		vdotop, vmagnop, tmagnop,
		vecop,					(* vector operators *)
		vmakeop, unitvop, vaddop, vsubop, crossvop, vnegop,
		svmulop, vsmulop, vsdivop, tvmulop, wrtop,
		tposop, taxisop,
		transop,				(* trans operators *)
		tmakeop, torientop, ttmulop, tvaddop, tvsubop, tinvrtop,
		vsaxwrop, constrop, ftofop, deproachop, fmakeop, vmkfrcop,
		ioop,					(* i/o operators *)
		queryop, inscalarop,
		specop,					(* special operators *)
		arefop, callop, grinchop, macroop, vmop, adcop, dacop,
		badop,
		addop, subop, negop, mulop, divop, absop); (* for parsing *)

leaftypes = pconstype..strngtype;

reltypes = sltop..sgtop;
forcetypes = (force,absforce,torque,abstorque,angvelocity);

node = record
	next: nodep;
	case ntype: nodetypes of
    exprnode:	(op: exprtypes; arg1, arg2, arg3: nodep; elength: integer);
    leafnode:	(case ltype: leaftypes of
	varitype:  (vari: varidefp; vid: identp);
	pconstype: (cname: varidefp; pcval: nodep);
	svaltype:  (s: scalar; wid: integer);
	vectype:   (v: vectorp);
	transtype: (t: transp);
	strngtype: (length: integer; str: strngp) ); (* also used by commentnodes *)
    listnode:	(lval: nodep);
    errornode:	(eexpr: nodep);
    calcnode: 	(rigid, frame1: boolean; other: dump; case tvarp: boolean of 
		    false: (tval: transp); true: (tvar: dump) );
    arraydefnode: (numdims: 1..10; bounds: nodep; combnds: boolean);
    bnddefnode:	(lower, upper: nodep);
    bndvalnode:	(lb, ub, mult: integer);
    waitlistnode: (who: dump; when: integer);
    procdefnode:(ptype: datatypes; level: 0..255;
		    pname, paramlist: varidefp; body: statementp);
    tlistnode:	(tok: tokenp);
    dimnode:	(time, distance, angle, dforce: integer);
	end;

(* records for parser: ident, token, resword *)

ident = record
	    next: identp;
	    length: integer;
	    name: strngp;
	    predefined: varidefp;
	  end;


tokentypes = (reswdtype, identtype, constype, comnttype, delimtype, labeldeftype,
		macpartype);

constypes = svaltype..strngtype;

reswdtypes = (stmnttype, filtype, clsetype, decltype, optype, edittype);

filtypes = (abouttype,alongtype,attype,bytype,defertype,dotype,elsetype,
		errmodestype,fromtype,handtype,intype,nonrigidlytype,rigidlytype,
		sourcefiletype,steptype,thentype,totype,untltype,viatype,
		withtype,worldtype,zeroedtype,oftype,wheretype,nowaittype,
		ontype,offtype,ppsizetype,collecttype,alltype,lextype);

clsetypes = (approachtype,arrivaltype,departuretype,departingtype,durationtype,
		errortype,forcetype,forceframetype,forcewristtype,gathertype,
		nildeproachtype,nonullingtype,nullingtype,stiffnesstype,
		torquetype,velocitytype,wobbletype,
		cwtype,ccwtype,stopwaittimetype,angularvelocitytype,
		fxtype,fytype,fztype,mxtype,mytype,mztype,
		t1type,t2type,t3type,t4type,t5type,t6type,tbltype);

edittypes = (getcmd,savecmd,insertcmd,renamecmd,startcmd,gocmd,proceedcmd,
		stepcmd,sstepcmd,nstepcmd,gstepcmd,executecmd,setcmd,tracecmd,
		breakcmd,unbreakcmd,tbreakcmd,definecmd,markcmd,unmarkcmd,
		popcmd);

token = record
	  next: tokenp;
	  case ttype: tokentypes of
constype:   (cons: nodep);
comnttype:  (len: integer; str: strngp);
delimtype:  (ch: ascii);
reswdtype:  (case rtype: reswdtypes of
	stmnttype: (stmnt: stmntypes);
	filtype:   (filler: filtypes);
	clsetype:  (clause: clsetypes);
	decltype:  (decl: datatypes);
	optype:	   (op: exprtypes);
	edittype:  (ed: edittypes) );
identtype:  (id: identp);
labeldeftype: (lab: varidefp);
macpartype: (mpar: varidefp);
	end;


resword = record
	  next: reswordp;
	  length: integer;
	  name: strngp;
	  case rtype: reswdtypes of
	stmnttype:  (stmnt: stmntypes);
	filtype:    (filler: filtypes);
	clsetype:   (clause: clsetypes);
	decltype:   (decl: datatypes);
	optype:	    (op: exprtypes);
	edittype:  (ed: edittypes);
	  end;

(* process descriptor blocks & environment record definitions *)

queuetypes = (nullqueue,nowrunning,runqueue,inputqueue,eventqueue,sleepqueue,
		forcewait,devicewait,joinwait,proccall);

cmoncb = record
	   running, enabled: boolean;		(* cmon's status *)
	   cmon: statementp;
	   pdb: dump;
	   evt: dump;
	   fbits: integer;			(* bits for force sensing *)
	   oldcmon: cmoncbp;			(* for debugger *)
	 end;

(* print related records: *)

cursorp = record
	  cline,ind: integer;
	  case stmntp: boolean of
  true:    (st: statementp);
  false:   (nd: nodep);
	 end;

linerec = record
	next: linerecp;
	start,length: integer
       end;

listingarray = packed array [0..listinglength] of ascii;

(* Global variables *)

var 
	(* From ALMAIN *)
    b:boolean;		
    ch:ascii;
    ltime: real;

	(* From PARSE *)
    reswords: array [0..26] of reswordp;
    idents: array [0..26] of identp;
    macrostack: array [1..10] of tokenp;
    curmacstack: array [1..10] of varidefp;
    macrodepth: integer;
    curchar, maxchar, curline: integer;
    curBlock,newDeclarations: statementp;
    curProc: dump;
    pnode: nodep;
    nodim, distancedim, timedim, angledim,
      forcedim, torquedim, veldim, angveldim: dump;
    fvstiffdim, mvstiffdim: nodep;
(*  filedepth: integer;
    curpage: integer;
    sysVars,unVars: dump;
    errcount: integer;
    outerBlock: statementp;
    curVariable: dump;
    curMotion: statementp;
    endOk,coendOk: integer;
    moveLevel: integer;
    curErrhandler, curCmon: statementp;	*)
    d1: array[1..13] of dump;
    endOfLine, backup, expandmacros, flushcomments, dimCheck: boolean;
(*  semiseen, shownline: boolean;
    eofError: boolean;
    inMove,inCoblock: boolean;	*)
    d2,d3,d4,d5,d6: boolean;
    curtoken: token;
    file1,file2,file3,file4,file5: atext;
    line: linestr;

	(* From INTERP *)
(*  curInt, activeInts, readQueue, allPdbs: dump;
    curEnv, sysEnv: dump;
    clkQueue: nodep;
    allEvents: dump;
    STLevel: integer;		
    etime: integer;		
    curtime: integer; 		
    stime: integer;		
    msg: dump;			
    inputp: integer;		
    debugLevel: integer;	*)
    d20: array[1..15] of integer;
    tSingleThreadMode: boolean;
    resched, running, escapeI, singleThreadMode: boolean;
    msgp: boolean;		(* flag set if any messages pending *)
    inputReady: boolean;
    inputLine: array [1..20] of ascii;

	(* From EDIT *)
    lines: array [1..maxLines] of linerecp; 
    ppLines: array [1..maxPPLines] of linerecp;	
    marks: array [1..20] of integer;
    cursorStack: array [1..15] of cursorp;
    bpts: array [1..maxBpts] of statementp;
    tbpts: array [1..maxTBpts] of statementp;
    debugPdbs: array [0..10] of dump;
    screenheight,dispHeight: integer;
    ppBufp,oppBufp,ppOffset,ppSize,nmarks: integer;
    lbufp,cursor,ocur,cursorLine,fieldnum,lineNum,findLine,pcLine: integer;
    firstDline,topDline,botDline,firstLine,lastLine: integer;
    freeLines,oldLines: linerecp;
    findStmnt: statementp;
    nbpts,ntbpts: integer;
    eCurInt: dump;
    dProg: statementp;	
    smartTerminal: boolean; 
    setUp,setExpr,setCursor,dontPrint,outFilep,newVarOk,collect: boolean;
    backUp: boolean;			
    eSingleThreadMode: boolean;	
    listing: packed array [0..listinglength] of ascii;
    lbuf: array [1..160] of ascii;
    ppBuf: array [1..100] of ascii;
    outFile: atext;
    curToken: token;			

	(* Various device & variable pointers *)
    speedfactor: dump;
    barm: dump;

	(* Various constant pointers *)
    xhat,yhat,zhat,nilvect: vectorp;
    niltrans: transp;
    bpark, ypark, gpark, rpark: transp;		(* arm park positions *)

{ Externally defined routines from elsewhere: }

	(* From ALLOC *)
procedure relVector(v: vectorp);				external;

	(* From EROOT *)
function epTaxis (t: transp): vectorp; 				external;
function epTmagn (t: transp): scalar; 				external;

	(* From PP *)
function getLine(length: integer): linerecp;			external;
procedure relLine(l: linerecp);					external;
procedure ppLine; 						external;
procedure ppOutNow; 						external;
procedure ppChar(ch: ascii); 					external;
procedure pp5(ch: c5str; length: integer); 			external;
procedure pp10(ch: cstring; length: integer); 			external;
procedure pp10L(ch: cstring; length: integer);			external;
procedure pp20(ch: c20str; length: integer); 			external;
procedure pp20L(ch: c20str; length: integer); 			external;
procedure ppInt(i: integer); 					external;
procedure ppStrng(length: integer; s: strngp); 			external;

	(* From DISP *)
procedure beep; 						external;
procedure outLine(line,col,start,length: integer); 		external;


procedure eputget; external;
procedure ePutGet; begin end;
(* print routines: putChar, put5, put10, putLine *)

procedure putChar(ch: ascii); external;
procedure putChar;
 var i: integer; l: linerecp;

    procedure out1Line(line,start,length: integer);	(* Also in EAUX1A *)
     begin
     if length > 79 then length := 79;      (* only display first 79 chars *)
     outLine(line,1,start,length);
     end;

 begin
 if ch = chr(15B) then
   begin			(* write out the line *)
   if lbufp > 160 then lbufp := 160;	(* in case there was an overflow *)
   if outFilep then
     begin			(* send line out to file *)
     for i := 1 to lbufp do write(outFile,lbuf[i]);
     writeln(outFile);		(* don't forget the crlf *)
     end
    else
     if (firstLine <= curLine) and (curLine <= lastLine) then
      if not (setup or dontPrint or fParse) then
       begin
       l := getLine(lbufp);		(* get a line to store chars in *)
       for i := 1 to lbufp do listing[l↑.start+i-1] := lbuf[i]; (* copy line *)
       for i := lbufp to l↑.length-1 do listing[l↑.start+i] := chr(0);
       i := curLine - topDline + 1;		(* index into lines array *)
       if lines[i] <> nil then
	 begin					(* complain *)
	 if ppBufp > 0 then ppLine;
	 pp5('Line ',5); ppInt(i-firstDline+1);
	 pp20(' wasn''t freed!  Old ',20); pp5('len: ',5);
	 ppInt(lines[i]↑.length);
	 pp10(' New len: ',10); ppInt(l↑.length); ppLine;
	 relLine(lines[i]);
	 end;
       lines[i] := l;				(* add to display list *)
       i := i - firstDline + 1;			(* where it goes on screen *)
       if (0 < i) and (i <= dispHeight) then
	 out1Line(i,l↑.start,lbufp);		(* & display it *)
       end;
   curLine := curLine + 1;
   lbufp := 0;
   end
  else if ch <> chr(12B) then	(* flush linefeeds *)
   begin			(* add character to line buffer *)
   lbufp := lbufp + 1;
   if lbufp > 160 then
     begin
     if lbufp = 161 then
       begin pp20L('Line buffer overflow',20); ppLine; end
     end
    else lbuf[lbufp] := ch;
   end;
 end;

procedure put5(ch: c5str; length: integer); external;
procedure put5;
 var i: integer;
 begin
 for i := 1 to length do putChar(ch[i]);
 end;

procedure put10(ch: cstring; length: integer); external;
procedure put10;
 var i: integer;
 begin
 for i := 1 to length do putChar(ch[i]);
 end;

procedure putLine; external;
procedure putLine;
 begin
 putChar(chr(15B));		(* cr *)
 end;

(* aux print routines: putReal, putInt, putVec, putTrans, putStrng, putTlist *)

procedure putReal (s: real); external;
procedure putReal ;
 var i,j,si,expo: integer; sf: real;
 begin
 if s < 0 then begin putchar('-'); s := -s end;
 if s < 1E-20 then begin expo := 0; s := 0 end
  else
   begin 
   expo := trunc(ln(s)/ln(10.0));	(* how big is s? *)
   s := s / exp(expo * ln(10));	(* normalize it between 1.0 & 9.999... *)
   s := s + 0.0000005;			(* round it off too *)
   end;
 sf := 0.000001;
 i := 0;
 while (expo >= 0) and (i < 7) do
  begin
  si := trunc(s);			(* get next digit *)
  putchar(chr(ord('0') + si));
  s := 10.0 * (s - si);
  sf := 10 * sf;
  expo := expo - 1;
  i := i + 1;
  end;
 if expo > 0 then
   begin
   for j := 1 to expo do putchar('0'); 	(* print trailing zeros *)
   end
  else
   begin				(* deal with fractional part *)
   if i = 0 then putchar('0');
   if s > sf then putchar('.');
   for j := 1 to -expo-1 do putchar('0');  (* print leading zeros, if any *)
   while (s > sf) and (i < 7) do
    begin
    si := trunc(s);			(* get next digit *)
    putchar(chr(ord('0') + si));
    s := 10.0 * (s - si);
    sf := 10 * sf;
    i := i + 1;
    end;
   end;
 end;

procedure putInt(r: real); external;
procedure putInt;
 begin
 putReal(round(r));
 end;

procedure putVec(v: vectorp); external;
procedure putVec;
 var i: integer;
 begin
 put10('vector(   ',7);
 with v↑ do 
  for i := 1 to 3 do 
   begin
   putReal(val[i]);
   if i = 3 then putChar(')') else putChar(',');
   end;
 end;

procedure putTrans(t: transp); external;
procedure putTrans;
 var i: integer; v: vectorp;
 begin
 with t↑ do
  begin
  refcnt := refcnt + 1;
  put10('trans(rot(',10);
  v := eptaxis(t); putVec(v); relVector(v);
  putChar(',');
  putReal(eptmagn(t));
  put10(' * degrees',10); put10('),vector( ',9);
  for i := 1 to 3 do
   begin putReal(val[i,4]); if i = 3 then putChar(')') else putChar(',') end;
  put10(' * inches)',10);
  refcnt := refcnt - 1;
  end;
 end;

procedure putStrng(length: integer; s: strngp); external;
procedure putStrng;
 var i,j: integer;
 begin
 j := 1;
 for i := 1 to length do
  begin
  putchar(s↑.ch[j]);
  if j = 10 then begin j := 1; s := s↑.next; end
   else j := j + 1;
  end;
 end;

procedure putTlist(t: tokenp); external;
procedure putTlist;
 var b: boolean; i: integer; r: reswordp;

    (* Swiped from PARSE, since it's only called by EDIT *)
    function findResword(what: reswdtypes; which, where: integer): reswordp;
     var b: boolean; i: integer; r: reswordp;
     begin
     b := true;
     i := where;
     while b and (i<=26) do
      begin         (* try to find reserved word & print it out *)
      r := reswords[i];     (* try next bucket *)
      while b and (r <> nil) do
       with r↑ do
	if (what=rtype) and (which = ord(stmnt)) then b := false else r := next;
      i := i + 1;
      end;
     findResword := r;
     end;

 begin (*putTList *)
 while t <> nil do
  begin
  with t↑ do
   case ttype of
reswdtype:  begin
	    if (rtype=stmnttype) or
	       ((rtype=filtype) and
		((filler=withtype) or (filler=untltype) or (filler=viatype))) then
	      begin
	      putline;
	      put10('          ',10);
	      end
	     else putchar(' ');
	    r := findResword(t↑.rtype,ord(t↑.stmnt),0);
	    if r <> nil then putStrng(r↑.length,r↑.name);
	    end;
identtype:  begin
	    putchar(' ');
	    putstrng(id↑.length,id↑.name);
	    end;
macpartype: begin
	    putchar(' ');
	    with mpar↑.name↑ do putstrng(length,name);
	    end;
constype:   if cons↑.ltype = svaltype then
	      begin putchar(' '); putReal(cons↑.s) end
	     else
	      begin
	      put5(' "   ',2);
	      putstrng(cons↑.length,cons↑.str);
	      putchar('"');
	      end;
comnttype:  begin
	    putchar(' ');
	    putstrng(len,str);
	    end;
delimtype:  putchar(ch);
otherwise  {do nothing};
   end;
  t := t↑.next;
  end;
 end (* putTList *);

(* expression related routine: getExprLength *)

function getExprLength(n: nodep): integer; external;
function getExprLength;
 var i: integer;
 begin
 if n = nil then i := 10
  else
   with n↑ do
    if ntype = exprnode then i := elength
     else if ntype = leafnode then
      case ltype of
varitype:  i := vid↑.length;
pconstype: i := cname↑.name↑.length;
svaltype:  i := wid;
strngtype: i := length + 2;
vectype,
transtype: i := 99;	(* who knows??? *)
otherwise {do nothing};
       end
     else i := 0;		(* who knows how long it is *)
 getExprLength := i;
 end;

(* Expression output routine:  putExpr *)

procedure putexpr(n: nodep; opp: integer); external;
procedure putexpr;
 var rp, parg1, parg2: boolean; curp: integer; pn: nodep;

procedure lp;
 begin
 if curp < opp then begin putchar('('); rp := true end else rp := false;
 end;

 begin
 if n = nil then put10('/* expr */',10) else
 with n↑ do
  begin
  if ntype = leafnode then
    case ltype of
 svaltype:  putReal(s);
 vectype:   putVec(v);
 transtype: putTrans(t);
 strngtype: begin
	    putchar('"');
	    putStrng(length,str);
	    putchar('"');
	    end;
 varitype:  with vid↑ do putStrng(length,name);
 pconstype: with cname↑.name↑ do putStrng(length,name);
 otherwise {do nothing};
    end
   else			(* it must be an expression node *)
    begin
    rp := false;
    parg2 := false;
    parg1 := true;
    case op of
eqvop:	begin curp := 1; lp; putexpr(arg1,1); parg2 := true;
	 put5(' eqv ',5) end;
orop,
xorop:	begin curp := 2; lp; putexpr(arg1,2); parg2 := true;
	 if op = xorop then put5(' xor ',5)
	  else put5(' or  ',4) end;
andop:	begin curp := 3; lp; putexpr(arg1,3); parg2 := true;
	 put5(' and ',5) end;
sltop,
sleop,
seqop,
sgeop,
sgtop,
sneop:	begin curp := 4; lp; putexpr(arg1,4); parg2 := true;
	 case op of
    sltop: put5(' <   ',3);
    sleop: put5(' <=  ',4);
    seqop: put5(' =   ',3);
    sgeop: put5(' >=  ',4);
    sgtop: put5(' >   ',3);
    sneop: put5(' <>  ',4);
	  end;
	end;
saddop,
ssubop,
vaddop,
vsubop,
tvaddop,
tvsubop: begin curp := 5; lp; putexpr(arg1,5); parg2 := true;
	 if (op=saddop) or (op=vaddop) or (op=tvaddop) then put5(' +   ',3)
	  else put5(' -   ',3) end;
wrtop:	begin curp := 6; lp; putexpr(arg1,6); parg2 := true; put5(' wrt ',5); end;
smulop,
sdivop,
maxop,
minop,
idivop,
modop,
vdotop,
svmulop,
vsmulop,
vsdivop,
crossvop,
tvmulop,
ttmulop: begin curp := 7; lp; putexpr(arg1,7); parg2 := true;
	 if op = vdotop then put5(' .   ',3) else
	  if op = maxop then put5(' max ',5) else
	  if op = minop then put5(' min ',5) else
	  if op = idivop then put5(' div ',5) else
	  if op = modop then put5(' mod ',5) else
	  if (op=sdivop) or (op=vsdivop) then put5(' /   ',3)
	   else put5(' *   ',3);
	 end;
sexpop,
ftofop:	begin curp := 8; lp; putexpr(arg1,8); parg2 := true;
	 if op = sexpop then put5(' ↑   ',3) else put5(' ->  ',4); end;
intop:	put5('int( ',4);
unitvop: put5('unit(',5);
sqrtop:	put5('sqrt(',5);
expop:	put5('exp( ',4);
logop:	put5('log( ',4);
timeop:	begin
	put10('runtime   ',7);
	with arg1↑ do
	 if (ntype <> leafnode) or (ltype <> svaltype) or (s <> 0.0) then
	   putchar('(')
	  else parg1 := false;
	end;
sinop:	put5('sin( ',4);
cosop:	put5('cos( ',4);
tanop:	put5('tan( ',4);
asinop:	put5('asin(',5);
acosop:	put5('acos(',5);
tposop:	put5('pos( ',4);
taxisop: put5('axis(',5);
specop: putchar('(');
negop,	(* this and above used in dimension statement *)
tinvrtop: put5('inv( ',4);
torientop: put10('orient(   ',7);
deproachop: put10('deproach( ',9);
adcop:	 put5('adc( ',4);
dacop,
atan2op,
vsaxwrop,
tmakeop,
fmakeop,
constrop,
vmakeop: begin parg1 := false;
	 if op = atan2op then put10('atan2(    ',6) else
	  if op = vsaxwrop then put5('rot( ',4) else
	  if op = tmakeop then put10('trans(    ',6) else
	  if op = fmakeop then put10('frame(    ',6) else
	  if op = vmakeop then put10('vector(   ',7) else
	  if op = constrop then put10('construct(',10)
	   else put5('dac( ',4);
	 putexpr(arg1,0); putchar(','); putexpr(arg2,0);
	 if (op=vmakeop) or (op=constrop) then
	  begin putchar(','); putexpr(arg3,0) end;
	 putchar(')');
	 end;
sabsop,
vmagnop,
tmagnop: begin parg1 := false; putchar('|'); putexpr(arg1,0); putchar('|') end;
inscalarop: begin parg1 := false; put10('inscalar  ',8) end;
grinchop: begin parg1 := false; putchar('#') end;
snegop,
vnegop,
notop:	begin parg1 := false;
	if op = notop then put5(' not ',5) else put5(' -   ',2);
	putexpr(arg1,9)
	end;
queryop,
arefop,
jointop,
macroop,
callop:	begin parg1 := false;
	if op = queryop then 
	  begin put5('query',5);
	   if arg2 <> nil then putchar('(')
	  end
	 else begin
		with arg1↑.vid↑ do putStrng(length,name);
		if (op = arefop) or (op = jointop) then putchar('[')
		 else if arg2 <> nil then putchar('(')
	      end;
	pn := arg2;
	while pn <> nil do
	 begin
	 if op = macroop then putTlist(pn↑.tok) else putexpr(pn↑.lval,0);
	 pn := pn↑.next; 
	 if pn <> nil then putchar(',');
	 end;
	if (op = arefop) or (op = jointop) then putchar(']')
	 else if arg2 <> nil then putchar(')');
	end;
badop:	begin parg1 := false;
	put10('(*bad-*)  ',9);
	putexpr(arg1,0);
	put10('(*-bad*)  ',9);
	end;
otherwise {do nothing - shouldn't happen! };
     end;
    if parg2 then putexpr(arg2,curp)
     else if parg1 then begin putexpr(arg1,0); putchar(')') end;
    if rp then putchar(')');
    end;
  end;
 end;